import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

class Loading {
  static showLoading() {
    if (Get.isDialogOpen == true) {
      return;
    }
    Get.dialog(
        Align(
          child: Container(
            width: 80,
            height: 80,
            decoration: BoxDecoration(
              color: Colors.black.withOpacity(0.65),
              borderRadius: BorderRadius.all(Radius.circular(8)),
            ),
            child: Theme(
              data: ThemeData(
                cupertinoOverrideTheme: CupertinoThemeData(
                  brightness: Brightness.dark,
                ),
              ),
              child: CupertinoActivityIndicator(
                radius: 14,
              ),
            ),
          ),
        ),
        barrierDismissible: false,
        barrierColor: Colors.transparent,
        transitionDuration: const Duration(milliseconds: 150),
        routeSettings: RouteSettings(name: 'dialog'));
  }

  static hideLoading() {
    if (Get.isDialogOpen == true) {
      Get.back();
    }
  }
}
